﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;

namespace MyMusicPlay._4._0
{
    public partial class MainWindow : Window
    {
        private bool Scroll_Play_Judge = false;
        Point MusicWeiZhi;
        /// <summary>
        /// 音乐下拉条 开始
        /// </summary>
        private void PlayDot_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (!Scroll_Play_Judge)
            {
                Scroll_Play_Judge = true;
                MusicWeiZhi = e.GetPosition(this);

                ScrollToPlaying.TimeOutAnim();
            }
        }
        /// <summary>
        /// 音乐下拉条 移动
        /// </summary>        
        private void ScrollPlay_MouseMove(object sender, MouseEventArgs e)
        {
            if (Scroll_Play_Judge)
            {
                var point = e.GetPosition(this);
                ScrollToPlaying.UpdateDotPoi(MusicWeiZhi.X, point.X);
                MusicWeiZhi = point;
            }
        }
        /// <summary>
        /// 音乐下拉条 停止
        /// </summary>
        private void ScrollPlay_MouseLeave(object sender, MouseEventArgs e)
        {
            if (Scroll_Play_Judge)
            {
                Scroll_Play_Judge = false;
                var seconds = ScrollToPlaying.GetCurrPlayTime();

                if (Media.playState == Media.PlayState.Playing)
                {
                    Media.UpdatePlayPoi(seconds);
                    ScrollToPlaying.State(true);
                }
            }
        }
        /// <summary>
        /// 音乐下拉条 停止
        /// </summary>
        private void ScrollPlay_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (Scroll_Play_Judge)
            {
                Scroll_Play_Judge = false;
                var seconds = ScrollToPlaying.GetCurrPlayTime();

                if (Media.playState == Media.PlayState.Playing)
                {
                    Media.UpdatePlayPoi(seconds);
                    ScrollToPlaying.State(true);
                }
            }
        }
    }
}
